import Const from './const';
import NetUtils from './NetUtils';
import LogUtils from './LogUtils';
import './sysext';
import PromiseUtils from './PromiseUtils';
import ObjectUitls from './ObjectUtils';

const Utils = global.Utils = {
    ...PromiseUtils,
    ...NetUtils,
    ...LogUtils,
    ...ObjectUitls,
    
    // eslint-disable-next-line no-empty-function
    noop() { 
        return Utils.noop; 
    },
    
    async loadImage(src) {
        return new Promise((resolve, reject) => {
            let img = new Image();
            img.onload = function() {
                resolve(img);
            };
            img.onerror = function(err) {
                reject(err);
            };
            img.src = src;
        });
    },

};


(function() {
    window.TilesetAdapter = {};
    window.TilesetFeature = {};
    window.Config = {
        tileWidth: Const.TileWidth,
        paletteWidth: Const.TileWidth * Const.PaletteTileCountPerLine
    };

    window.Plugins = [
        {
            path: '/plugin/0/core/1.0.0/index.js',
            key: '/plugin/0/core'
        }
    ];

    window.M = {};

    window.init = {
        async loadPlugins() {
            //not implement
        }
    };

    window.init.loadPlugins()
        .then()
        .catch(Utils.error);
})();

export default Utils;